package cn.edu.uestc.smgt.aspect;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import cn.edu.uestc.smgt.pojo.Manager;

//@Component
//@Aspect
public class ManagerLoginAspect {

	//@Before("@annotation(org.yangtse.life.annotation.UserLoginAuthorized)")
	public void checkManagerLogin(JoinPoint joinPoint) throws IOException {
		HttpServletRequest request = (HttpServletRequest) joinPoint.getArgs()[0];
		HttpServletResponse response = (HttpServletResponse) joinPoint.getArgs()[1];
		HttpSession session = request.getSession();
		Manager mgr = (Manager) session.getAttribute("manager");
		if (mgr == null) {
			response.sendRedirect("/studentmanagement/login.html");
			return;
		}
	}

}
